<template>
  <el-table
    :data="list"
    style="width: 100%"
    row-key="id"
    border
    :tree-props="{ children: 'children' }"
  >
    <el-table-column prop="title" label="活动名称"> </el-table-column>
    <el-table-column label="状态">
      <template slot-scope="scope">
        <el-button type="primary" v-if="scope.row.status == 1">启用</el-button>
        <el-button type="info" v-else>禁用</el-button>
      </template>
    </el-table-column>
    <el-table-column prop="name" label="操作">
      <template slot-scope="scope">
        <el-button type="primary" @click="handleEdit(scope)">编辑</el-button>
        <del-btn @confirm="del(scope)"></del-btn>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { reqseckdelete } from "../../../http/api";
import { successAlert } from "../../../utils/alert";
import { mapGetters, mapActions } from "vuex";

export default {
  components: {},
  props: [],
  data() {
    return {};
  },
  methods: {
    ...mapActions({
      reqList: "seck/reqList",
    }),
    handleEdit(scope) {
      this.$emit("willUpdate", scope.row.id);
    },
    del(scope) {
      reqseckdelete({
        id: scope.row.id,
      }).then((res) => {
        if (res.data.code == 200) {
          //弹成功
          successAlert(res.data.msg);
          //重新获取list
          this.reqList();
        }
      });
    },
  },
  mounted() {
    //触发
    this.reqList();
  },
  computed: {
    ...mapGetters({
      list: "seck/list",
    }),
  },
  watch: {},
};
</script>
<style scoped lang="less">
@import "../../../less/index.less";
img {
  width: 50px;
  height: 50px;
}
</style>
